get comments
Retrieve comments from TabNews content by specifying the username and slug, enabling easy access to user discussions and feedback on articles.
Instructions
get comments from a content on tabnews api
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | The slug to get the content | |
| username | Yes | The username to get the content |
Implementation Reference
- src/tools/status.ts:164-186 (handler)The async handler function that implements the core logic of the 'get comments' tool. It calls getContentChildren API with username and slug, formats the result as JSON text, and returns it in MCP response format. Handles errors by throwing descriptive messages.handler: async (params: GetContentParams): Promise<McpResponse> => { try { const result = await getContentChildren({ username: params.username, slug: params.slug, }); const content: McpTextContent = { type: "text", text: `Comments:\n\n${JSON.stringify(result, null, 2)}`, }; return { content: [content], }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get comments: ${error.message}`); } else { throw new Error("Failed to get comments"); } } },
- src/tools/status.ts:160-163 (schema)Zod schema defining the input parameters for the tool: username (string) and slug (string).parameters: { username: z.string().describe("The username to get the content"), slug: z.string().describe("The slug to get the content"), },
- src/index.ts:52-57 (registration)Registers the 'get comments' tool (imported as getContentChildrenTool) with the MCP server by passing its name, description, parameters schema, and handler function.server.tool( getContentChildrenTool.name, getContentChildrenTool.description, getContentChildrenTool.parameters, getContentChildrenTool.handler );
- src/index.ts:9-9 (registration)Import of the getContentChildrenTool from src/tools/status.ts for registration.getContentChildrenTool,
- src/tools/status.ts:157-187 (registration)Full tool object definition and export, including name 'get comments', description, parameters schema, and handler.export const getContentChildrenTool = { name: "get comments", description: "get comments from a content on tabnews api", parameters: { username: z.string().describe("The username to get the content"), slug: z.string().describe("The slug to get the content"), }, handler: async (params: GetContentParams): Promise<McpResponse> => { try { const result = await getContentChildren({ username: params.username, slug: params.slug, }); const content: McpTextContent = { type: "text", text: `Comments:\n\n${JSON.stringify(result, null, 2)}`, }; return { content: [content], }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get comments: ${error.message}`); } else { throw new Error("Failed to get comments"); } } }, };